Skip to content

(feat): support building against AWS-LC as the libcrypto - #435

Open
prasden wants to merge 2 commits into
OpenVPN:masterfrom
prasden:awslc-integration
Open

prasden wants to merge 2 commits into
OpenVPN:masterfrom
prasden:awslc-integration

Conversation

@prasden

@prasden prasden commented Jun 2, 2026 •

Copy link
Copy Markdown

Addresses #434

Changes:

This PR adds support for building OpenVPN3 against AWS-LC as the libcrypto/libssl backend, selected by the flag -DUSE_AWSLC=ON and CMAKE_PREFIX_PATH pointing at the AWS-LC install.

For AWS-LC divergences, openvpn/openssl/aws-lc-compat.hpp was added. AWS-LC reports itself as OpenSSL 1.1.1, so it reuses the existing OpenSSL code and the 1.1.x shims in compat.hpp.

AWS-LC differences:

  • AWS-LC has no BIOerr macro. aws-lc-compat.hpp defines it as OPENSSL_PUT_ERROR(BIO, r), the same way AWS-LC defines RSAerr and SSLerr.
  • AWS-LC names reason code 1116 SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED. aws-lc-compat.hpp aliases SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED to it.
  • AWS-LC has no SSL_R_CA_MD_TOO_WEAK, SSL_R_CA_KEY_TOO_SMALL, SSL_R_DH_KEY_TOO_SMALL or EVP_PKEY_DSA1..4. Their case labels are wrapped in #ifdef, like the existing SSL_R_LEGACY_SIGALG_DISALLOWED_OR_UNSUPPORTED.
  • AWS-LC has no EVP_PKEY_TLS1_PRF. TLS1PRF::PRF has a third variant for AWS-LC that calls CRYPTO_tls1_prf, the same as OpenVPN 2.x.
  • AWS-LC's SSL_CTX_set_security_level does nothing. AWS-LC uses the existing branch that only accepts tls-cert-profile legacy and rejects other profiles.
  • AWS-LC has RSA_meth_set0_app_data but no RSA_meth_get0_app_data. The external PKI RSA class stores its this pointer in its own ex_data index, the same way ExternalPKIECImpl does.
  • AWS-LC's EC_KEY_METHOD_set_sign requires sign_setup to be NULL. The empty ecdsa_sign_setup stub is removed and NULL is passed.
  • AWS-LC's SSL_CIPHER_description returns a const char * that cannot be freed without a cast. The caller now passes a stack buffer instead.
  • AWS-LC's GCM finalizes when EVP_EncryptUpdate or EVP_DecryptUpdate gets a NULL input. The AAD update is skipped when there is no AAD.
  • AWS-LC's PKCS7_verify rejects a NULL X509_STORE, even with PKCS7_NOVERIFY. The caller now passes an empty store.

Testing

Built against AWS-LC and verified that all unit tests passed (591/591) and also verified OpenVPN3 was able to build against stock OpenSSL, passing all unit tests, confirming there were no regressions from the changes.

To test building against AWS-LC: see aws-lc/BUILDING.md for prerequisites

Build AWS-LC

git clone https://github.com/aws/aws-lc.git
 cmake -GNinja -B aws-lc/build -S aws-lc \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_INSTALL_PREFIX=aws-lc/install
 ninja -C aws-lc/build install

Build OpenVPN3 using AWS-LC as the SSL backend and run the tests:

cmake -B build-awslc -S . -DUSE_AWSLC=ON -DCMAKE_PREFIX_PATH=/path/to/aws-lc/install
cmake --build build-awslc --target coreUnitTests ovpncli

@prasden
prasden force-pushed the awslc-integration branch from 0513258 to c442e6e Compare June 2, 2026 18:05
@schwabe
schwabe self-requested a review June 2, 2026 22:26

@schwabe schwabe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started reviewing this buit I think the PR needs a bit of overhaul in the general strategy to wherever possible to avoid the ifdefs directly in the code and instead try to use compat.hpp instead.

It seems that this PR also ignores a lot of the compat stuff that is already there for OpenSSL 1.1.x that has its own compat layer and instead adds its own distinct ifdef/compat stuff.

That generates extra code to maintain.

To be honest, this PR feels a bit like AI was used and then not really cleaned up by a human enough to make it actually good/maintainable code.

Comment thread openvpn/openssl/util/error.hpp Resolved
Comment thread openvpn/openssl/util/error.hpp Resolved
Comment thread openvpn/openssl/util/error.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/sign/pkcs7verify.hpp Resolved
@prasden

prasden commented Jun 5, 2026

Copy link
Copy Markdown
Author

Thank you for the feedback. I am going to close this PR and open a different one more in line with using compat.hpp instead of in line definitions.

@prasden prasden closed this Jun 5, 2026
@ordex

ordex commented Jun 6, 2026

Copy link
Copy Markdown
Member

You could also force push to the same branch, instead of opening new PRs each time. It's less noisy and easier to follow, because we don't lose older comments.

@schwabe

schwabe commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Yes. I agree with @ordex please force push to this PR and reopen it if you have a new version.

@prasden prasden reopened this Jun 8, 2026
@prasden
prasden force-pushed the awslc-integration branch from bfd1830 to 3bbd685 Compare June 8, 2026 05:03
@prasden
prasden force-pushed the awslc-integration branch from 3bbd685 to 799541e Compare June 8, 2026 05:06
@prasden

prasden commented Jun 8, 2026

Copy link
Copy Markdown
Author

Ack, reopened with the force pushed changes and edited the PR description. Thanks!

@prasden
prasden requested a review from schwabe June 8, 2026 07:04
@prasden

prasden commented Sep 24, 2026

Copy link
Copy Markdown
Author

Gentle bump @schwabe?

Comment thread cmake/findcoredeps.cmake Resolved
Comment thread openvpn/openssl/crypto/tls1prf.hpp Resolved
Comment thread openvpn/openssl/pki/extpki.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/ssl/sslctx.hpp Resolved
Comment thread openvpn/openssl/aws-lc-compat.hpp Resolved
@schwabe

schwabe commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I only did a very light review and already found multiple issues.

This is a bit better but it is still feels like this has not be gone through proper human reviewing and looking at the changes if they really make sense. A lot of the changes still feel sloppy.

The OpenVPN 2.x patches from your colleguage had a much better quality and that is why they were accepted with relatively small changes. I strongly suggest to review this PR yourself again or let some colleguage review it before resubmitting.

@schwabe

schwabe commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@prasden are you still interested in cleanup up this PR?

@prasden

prasden commented Nov 2, 2026 •

Copy link
Copy Markdown
Author

@schwabe -- thanks for the swift feedback. Yes, let me take a look and clean up by end of tomorrow.

@prasden

prasden commented Nov 3, 2026 •

Copy link
Copy Markdown
Author

@schwabe -- addressed latest feedback in 3b065e9. Also updated PR description to match.

@prasden
prasden requested a review from schwabe November 10, 2026 21:11
@prasden

This comment was marked as low quality.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants